# -*- encoding=utf8 -*-
__author__ = "Administrator"

from airtest.core.api import *
from airtest.cli.parser import cli_setup

if not cli_setup():
    #auto_setup(__file__, logdir=True, devices=["android://127.0.0.1:5037/c9a55ee3?cap_method=ADBCAP&touch_method=MAXTOUCH&",]) # xiaomi
    auto_setup(__file__, logdir=True, devices=["android://127.0.0.1:5037/472eedaa?cap_method=ADBCAP&touch_method=MAXTOUCH&",]) # oppo



# script content
print("start...")


while True:
    if exists(Template(r"tpl1750227598640.png", record_pos=(0.062, -0.328), resolution=(1080, 2340))):
        touch(Template(r"tpl1750227622272.png", record_pos=(0.379, -0.336), resolution=(1080, 2340)))

    sleep(31)

    touch(Template(r"tpl1750227368192.png", record_pos=(-0.18, -0.915), resolution=(1080, 2340)))
    if exists(Template(r"tpl1750227485731.png", record_pos=(0.012, 0.292), resolution=(1080, 2340))):
        touch(Template(r"tpl1750227500326.png", record_pos=(-0.002, 0.252), resolution=(1080, 2340)))
        sleep(1.0)
        touch(Template(r"tpl1750227368192.png", record_pos=(-0.18, -0.915), resolution=(1080, 2340)))
        


#     keyevent("BACK")
    


# 1 出弹窗#
# 2 下载“悟空浏览器”


# generate html report
# from airtest.report.report import simple_report
# simple_report(__file__, logpath=True)